Search
Summary

COVID-19 Outbreak Data

This short report has been created using Jupyter Book and tries to visualize and analyze some data related to the COVID-19 outbreak.

The data are constantly updated from the repository by Johns Hopkins CCSE.

This is a work-in-progress, graphs will be addedd in the next days and week.

Interactive charts have been generated using plotly.

Method

We group the data (confirmed cases and deaths per day) for a single country, computing few derived quantities, such as daily new cases, mortality rate, and an estimate of the reproduction number (R0). Then, we can analyze one or more countries at the same time.

import os,sys
sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath(''), '../../Code')))
from hedera_covid import DataHandler, plot_death_rate, plot_daily_cases, plot_confirmed_cases



# for plotly
from plotly.offline import iplot
from plotly.offline import init_notebook_mode, plot
from IPython.core.display import display, HTML
import plotly as py
import plotly.tools as tls

import numpy as np

# load data
path_confirmed = '../../Data/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv'
path_death = '../../Data/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv'

europe_covid_data = DataHandler(data_confirmed_path = path_confirmed,data_death_path = path_death)
america_covid_data = DataHandler(data_confirmed_path = path_confirmed,data_death_path = path_death)

Europe

Europe = ['Italy','Spain','Germany','France','United Kingdom',
          'Netherlands','Belgium','Portugal','Sweden','Austria']

for c in Europe:
    europe_covid_data.add_country(c)

Total number of cases

The number of (reported) cases is strongly dependent on the capacity and on the politics of each country in terms of tests. Realistic estimates can only be obtained starting from (realistic estimates of) the number of deaths and of the death rate.

Nevertheless, the number of reported cases can provide a measure of the spread of the virus.

The following figure shows the number of reported cases, shifting the curves so that they start when the number of infected persons reached 100. The number has also been smoothed taking, for each day, the average of a week (3 days before and 3 days after).

You can double click on a country name on legend to isolate its data. Simple clicking on a name will switch on/off the corresponding data.

# confirmed
data = europe_covid_data.get_confirmed_data(start_date=0,n_smooth=0,rescale=True)
covid_data = europe_covid_data
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Confirmed Cases (rescaled in each country)"}}
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Daily variation

data = europe_covid_data.get_daily_confirmed_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Daily Cases (rescaled)"}}
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

These curves show whether and how the different countries are able to flatten the curves. Try to double-click on the legend, then switch on, country by country, e.g., comparing Italy, Germany, and Spain.

Note These data are dependent on the testing policy of each country. For example, at the beginning of April Italy drastically increased the number of performed test, which might result in an increase of reported cases.

Number of deaths

data = europe_covid_data.get_deaths_data(start_date=40,n_smooth=7,rescale=False)
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Total deaths (rescaled)"}, "legend_orientation": "h", 
              "legend" :{"x":0.3, "y": 1.15}
              }
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Daily variation

To look at the daily variation, we can rescale the curves setting the first day when at least 5 deaths were reported.

data = europe_covid_data.get_daily_deaths_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Daily deaths (rescaled)"}, "legend_orientation": "h"}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Mortality Rate

The following figure shows the mortality rate (# of reported death/# of reported cases) for each country/

data = europe_covid_data.get_death_rate_data(start_date=40,n_smooth=0,rescale=False)
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Mortality rate"},
               "font_size":10,
              "legend": {'x':1.05}
              }
}
plot(fig,filename = 'figure.html')
display(HTML('figure.html'))

Americas

America = ['US','Canada','Mexico','Colombia','Peru',
          'Chile','Brazil','Ecuador','Argentina']

for c in America:
    america_covid_data.add_country(c)

Total confirmed cases

# confirmed
data = america_covid_data.get_confirmed_data(start_date=0,n_smooth=0,rescale=True)

init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Confirmed cases (rescaled)"}, "legend_orientation": "h"}
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))
# confirmed
data = america_covid_data.get_confirmed_data(start_date=50,n_smooth=0,rescale=False)

init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Confirmed cases"}}
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Daily variation

data = america_covid_data.get_daily_confirmed_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Daily Cases (rescaled)"}}
}

plot(fig, filename = 'figure.html')
display(HTML('figure.html'))

Daily deaths

data = america_covid_data.get_daily_deaths_data(start_date=0,n_smooth=7,rescale=True)
init_notebook_mode(connected=True)

fig = {
    "data": data,
    "layout": {"title": {"text": "Daily deaths (rescaled)"}, "legend_orientation": "h"}
}
plot(fig, filename = 'figure.html')
display(HTML('figure.html'))